package Messages;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;

import ocsf.server.ConnectionToClient;
import server.SQLConnection;
/**
 * This class implements the delete private  from DB
 * @author Gabi Revah
 * @author Aviad Almog
 */ 
public class MessageDeletePrivate {
	private ConnectionToClient client ;
	private String[] str; 
	static int row1;
	int ordertemp;
/**
 * Contractor of this class 
 * @param str
 * @param client
 */
	public MessageDeletePrivate(String[] str, ConnectionToClient client){
		
		this.client= client ;
		this.str= str; 	
	
	}
	/**
	 * This method delete private from DB
	 * @throws SQLException
	 * @throws IOException
	 */
	public void DeletePrivate() throws SQLException, IOException{
	
		SQLConnection sc = new SQLConnection();
		java.sql.PreparedStatement ps=sc.getConnection().prepareStatement("DELETE FROM db.private where idprivate = ?;");
		java.sql.PreparedStatement ps1=sc.getConnection().prepareStatement("DELETE FROM db.order where idcostumer = ?;");
		java.sql.PreparedStatement ps2=sc.getConnection().prepareStatement("DELETE FROM db.assingment where idcostumer = ?;");

        ps.setString(1,str[1]);
        ps.executeUpdate();
        ps.close();
        
        ps1.setString(1,str[1]);
        ps1.executeUpdate();
        ps1.close();
        
        ps2.setString(1,str[1]);
        ps2.executeUpdate();
        ps2.close();
        
        client.sendToClient("DeletePrivate");


		
	}
	

}
